<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>新建预约考试</title>
<%@ include file="/WEB-INF/layouts/comm/kindeditor.jsp"%>
<%@ include file="/WEB-INF/layouts/comm/form.jsp"%>
<%@ include file="/WEB-INF/layouts/comm/laydate.jsp"%>
</head>
<body>
	<div class="mod_header">
		<div class="title">
			<h2 id="h_title">新建预约考试</h2>
		</div>
	</div>
	<ol class="breadcrumb">
		<li><a href="#">功能设置</a></li>
		<li><a href="${ctx}/webCustomer/exam/index">预约考试</a></li>
		<li class="active">新建预约考试</li>
	</ol>
	<div class="mod_basic">
		<div class="title">
			<h3>预约考试设置</h3>
		</div>

		<div class="content">
			<div class="sub_content">
				<form class="form-horizontal" id="exam_form" method="post">
					<div class="form-group">
						<label for="examTime" class="col-sm-2 control-label">考试日期</label>
						<div class="col-sm-10">
							<input type="text" class="form-control layer-date" id="examTime"
								name="examTime">
						</div>
					</div>
					<div class="form-group">
						<label for="resTime" class="col-sm-2 control-label">报名开始时间</label>
						<div class="col-sm-10">
							<input type="text" class="form-control layer-date" id="resTime"
								name="resTime">
						</div>
					</div>
					<div class="form-group">
						<label for="title" class="col-sm-2 control-label">标题</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="title" name="title">
						</div>
					</div>
					<div class="form-group">
						<label for="openHours" class="col-sm-2 control-label">考试开放时间</label>
						<div class="col-sm-10">
							<c:forEach var="examRange" items="${examRanges}"
								varStatus="status">
								<label class="checkbox-inline"> <input type="checkbox"
									id="openHours${status.index+1}" name="openHours"
									value="${examRange}"> ${examRange}
								</label>
							</c:forEach>
						</div>
					</div>
					<div class="form-group">
						<label for="title" class="col-sm-2 control-label">每时段最大报名数</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="joinNo" name="joinNo" value="40">
						</div>
					</div>
					<div class="form-group">
						<label for="escontent" class="col-sm-2 control-label">内容</label>
						<div class="col-sm-10">
							<textarea name="content" id="edit_content"
								style="width: 100%; height: 400px;"></textarea>
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-2 col-sm-10">
							<button type="submit" class="btn btn-primary">保存</button>
						</div>
					</div>

				</form>
			</div>
		</div>
	</div>
	<footer_body> <script>
		base.menu.active('menu_203');

		base.kindeditor.init('${ctx}', '#edit_content');

		base.form.validation("#exam_form", {
			rules : {
				examTime : {
					required : true
				},
				resTime : {
					required : true
				},
				openHours : {
					required : true
				},
				title : {
					required : true
				},
				joinNo : {
					required : true,
					maxlength:100,
					digits : true
				},
				content : {
					required : true
				}
			},
			ignore : ""
		});

		base.form
				.ajaxSubmit({
					formid : '#exam_form',
					cbfun : function(data) {
						if (data.data == true) {
							BootstrapDialog
									.show({
										message : "添加成功",
										size : BootstrapDialog.SIZE_SMALL,
										buttons : [
												{
													label : '继续添加',
													cssClass : 'btn-success',
													action : function(dialogRef) {
														window.location.href = "${ctx}/webCustomer/exam/add";
													}
												},
												{
													label : '查看预约考试信息',
													cssClass : 'btn-warning',
													action : function(dialogRef) {
														window.location.href = "${ctx}/webCustomer/exam/index";
													}
												} ]
									});
						} else {
							BootstrapDialog.alert("保存失败，请重试");
						}
					}
				});

		$("#examTime").val(laydate.now());

		function autotitle() {
			$("#title").val("(" + $("#examTime").val() + ")的预约考试");
		}

		autotitle();

		var exam_data = {
			elem : '#examTime',
			istime : false,
			format : 'YYYY-MM-DD',
			min : laydate.now(),
			choose : function(datas) {
				exam_last.max = datas //将结束日的初始值设定为开始日
				autotitle();//自动标题
			}
		};

		var exam_last = {
			elem : '#resTime',
			format : 'YYYY-MM-DD hh:mm:ss',
			istime : true,
			istoday : false,
			min : laydate.now(),
			choose : function(datas) {
				exam_data.min = datas;
			}
		};

		laydate(exam_data);
		laydate(exam_last);
	</script> </footer_body>
</body>
</html>